package com.neutech.dome;

import com.neutech.entity.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.util.List;

public class Demo1 {

    public static void main(String[] args) {
        // 创建SQL Session工厂,传入配置文件的地址
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(
                Demo1.class.getClassLoader().getResourceAsStream("mybatis.xml")
        );
        //创建SQL session的对象
        SqlSession session = factory.openSession();
        List<User> userList = session.selectList("UserMapper.listUser");
        for (User user : userList) {
            System.out.println(user);
        }

        //User user = session.selectOne("UserMapper.getUserById");
        //System.out.println(user);

    }

}
